fix: keep failed-upload cleanup inside the upload worker#5249
Open
Ma77Ball wants to merge 6 commits into
Open
Conversation
…era into fix/deleteObjectCalledTwice
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5249 +/- ##
============================================
- Coverage 48.95% 48.94% -0.02%
+ Complexity 2377 2373 -4
============================================
Files 1048 1048
Lines 40270 40269 -1
Branches 4272 4272
============================================
- Hits 19714 19708 -6
- Misses 19402 19405 +3
- Partials 1154 1156 +2
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
/request-review @Xiao-zhen-Liu |
Removed comment about reusing S3 for cleanup in upload worker. Signed-off-by: Matthew B. <mgball@uci.edu>
Contributor
|
Requesting review from @kunwp1 as he is maintaining these code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
What Caused the Issue:
LargeBinaryOutputStream looked up the S3 client twice: once in the upload worker (correct), and once again in close() during failed-upload cleanup. When a test left a stream unclosed, Python's GC eventually called del → close() → the second lookup, but by then a different test was active, so the cleanup hit the wrong test's mock_s3 and broke its assert_called_once_with.
Proposed Fix
s3.delete_object(...)from_cleanup_failed_upload()into the upload worker, reusing thes3client already captured by the closure that did the upload._cleanup_failed_upload()method and the call to it fromclose(); the worker now handles cleanup before recording the exception.close()and__del__no longer call back intolarge_binary_manager, so a finalizer firing under a later test's monkey-patches cannot reach the wrong S3 client.Any related issues, documentation, or discussions?
Closes: #5245 Follow-up to #4707; surfaced on the 3.12 leg of https://github.com/apache/texera/actions/runs/26481776334/job/77980417021.
How was this PR tested?
ruff formatandruff checkoveramber/src/main/pythonandamber/src/test/python(clean).test_large_binary_output_stream.pystill cover the relevant paths:test_close_handles_upload_error,test_delete_object_failure_is_swallowed, andtest_write_after_upload_error_raises_error.test_write_after_upload_error_raises_errorback to inline form and removed the_drainedhelper, both no longer needed once cleanup is structurally contained.Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in compliance with ASF